﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ComponentModel;

namespace FilesUploader.Model
{
    public class Photo : INotifyPropertyChanged
    {
        public Photo()
        {
            Percentage = 0;
            CurrentChunk = 0;
            Retries = 0;
            UploadState = UploadState.New;
        }

        public String PhotoBase64 { get; set; }
        private String _photoName;

        public String PhotoName
        {
            get { return _photoName; }
            set
            {
                _photoName = value;
                OnPropertyChanged("PhotoName");
            }
        }

        public string Extension { get; set; }

        private UploadState _uploadState;

        public UploadState UploadState
        {
            get { return _uploadState; }
            set
            {
                _uploadState = value;
                OnPropertyChanged("UploadState");
                OnPropertyChanged("InError");
            }
        }

        private int _percentage;

        public int Percentage
        {
            get { return _percentage; }
            set
            {
                _percentage = value;
                OnPropertyChanged("Percentage");
            }
        }

        //private SolidColorBrush _backGround;

        //public SolidColorBrush BackGround
        //{
        //    get { return _backGround; }
        //    set
        //    {
        //        _backGround = value;
        //        OnPropertyChanged("BackGround");
        //    }
        //}

        public System.IO.FileInfo File { get; set; }

        public int CurrentChunk { get; set; }

        public int NumberOfChunks { get; set; }

        public Visibility InError
        {
            get
            {
                return _uploadState == UploadState.Error ? Visibility.Visible : Visibility.Collapsed;
            }
        }

        public int Retries { get; set; }

        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;

        private void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
        #endregion
    }

    public enum UploadState
    {
        New,
        Uploaded,
        Error
    }

}
